<!-- 列表分类-风格 -->
<template>
    <el-collapse modelValue="1">
        <el-collapse-item title="组件风格" name="1">
            <div class="type-wrap">
                <div class="item" @click="classifyType = 1">
                    <div :class="['item-list', { 'active': classifyType === 1 }]">
                        <div v-for="item in 4" :key="item"></div>
                    </div>
                    <div class="item-title">一级横版</div>
                </div>
                <div class="item type-2" @click="classifyType = 2">
                    <div :class="['item-list', { 'active': classifyType === 2 }]">
                        <div v-for="item in 4" :key="item"></div>
                    </div>
                    <div class="item-title">二级横版</div>
                </div>
            </div>

            <el-divider></el-divider>
            <div class="mode-wrap">
                <template v-if="classifyType === 1">
                    <div class="classify-type-1">
                        <ul :class="['mode-0', { 'active': mode === 0 }]" @click="mode = 0">
                            <li class="item">
                                <span>全部</span>
                            </li>
                            <li v-for="item in 3" :key="item" :class="{ 'selected': item === 1 }" class="item">
                                <span>{{ `分类${item}` }}</span>
                            </li>
                        </ul>
                        <ul :class="['mode-1', { 'active': mode === 1 }]" @click="mode = 1">
                            <li class="item">
                                <span>全部</span>
                            </li>
                            <li v-for="item in 3" :key="item" :class="{ 'selected': item === 1 }" class="item">
                                <span>{{ `分类${item}` }}</span>
                            </li>
                        </ul>
                        <ul :class="['mode-2', { 'active': mode === 2 }]" @click="mode = 2">
                            <li class="item">
                                <span>全部</span>
                            </li>
                            <li v-for="item in 2" :key="item" :class="{ 'selected': item === 1 }" class="item">
                                <span>{{ `分类${item}` }}</span>
                            </li>
                            <li class="item">
                                <span>更多</span>
                            </li>
                        </ul>

                        <template v-if="mode === 2">
                            <div class="classify-icon-wrap">
                                <div class="title-ele">分类展开图标</div>
                                <div class="classify-icon-list-box">
                                    <si-image-picker
                                        v-model="horizontalImageSrc"
                                        :show-label="false"
                                        :size="50"
                                        type="image"
                                    />
                                </div>
                            </div>
                        </template>
                    </div>
                </template>
                <template v-if="classifyType === 2">
                    <div class="classify-type-2">
                        <ul :class="['mode-0', { 'active': mode === 0 }]" @click="mode = 0">
                            <li class="item">
                                <span>全部</span>
                                <span class="triangle"></span>
                            </li>
                            <li v-for="item in 3" :key="item" :class="{ 'selected': item === 1 }" class="item">
                                <span>{{ `分类${item}` }}</span>
                                <span class="triangle"></span>
                            </li>
                        </ul>
                        <ul :class="['mode-1', { 'active': mode === 1 }]" @click="mode = 1">
                            <li class="item">
                                <span>全部</span>
                                <span class="triangle2"></span>
                            </li>
                            <li v-for="item in 3" :key="item" :class="{ 'selected': item === 1 }" class="item">
                                <span>{{ `分类${item}` }}</span>
                                <span class="triangle2"></span>
                            </li>
                        </ul>
                    </div>
                </template>
            </div>

            <template v-if="classifyType === 2">
                <el-divider></el-divider>
                <div class="level2-classify-style">
                    <div
                        :class="['item-wrap', 'mode-0', { 'active': level2ClassifyStyle === 0 }]"
                        @click="level2ClassifyStyle = 0"
                    >
                        <ul>
                            <li class="item">
                                <span>全部</span>
                                <span class="triangle"></span>
                            </li>
                            <li v-for="item in 3" :key="item" :class="{ 'selected': item === 1 }" class="item">
                                <span>{{ `分类${item}` }}</span>
                                <span class="triangle"></span>
                            </li>
                        </ul>
                        <div class="open-warp">
                            <div v-for="item in 3" :key="item">
                                {{ `分类1-${item}` }}
                            </div>
                        </div>
                    </div>

                    <div
                        :class="['item-wrap', 'mode-1', { 'active': level2ClassifyStyle === 1 }]"
                        @click="level2ClassifyStyle = 1"
                    >
                        <ul>
                            <li class="item">
                                <span>全部</span>
                                <span class="triangle"></span>
                            </li>
                            <li v-for="item in 3" :key="item" :class="{ 'selected': item === 1 }" class="item">
                                <span>{{ `分类${item}` }}</span>
                                <span class="triangle"></span>
                            </li>
                        </ul>
                        <div class="open-warp">
                            <div v-for="item in 8" :key="item">
                                {{ `分类1-${item}` }}
                            </div>
                        </div>
                    </div>
                </div>

                <template v-if="level2ClassifyStyle === 1">
                    <layout-pane label="每行列数">
                        <si-input-number
                            v-model="widget.widgetData.eles.customFeature.level2ClassifyColumn"
                            :min="1"
                            :max="5"
                        />
                    </layout-pane>
                </template>
            </template>
        </el-collapse-item>
    </el-collapse>
</template>

<script>
import { defineComponent, toRefs, computed } from 'vue'
import LayoutPane from '@/components/setting-pane/layout-pane'
import {
    SiImagePicker,
    SiInputNumber
} from '@/components/setting-pane/setting-item'
export default defineComponent({
    name: 'NewClassifyMode',
    components: {
        LayoutPane,
        SiImagePicker,
        SiInputNumber
    },
    props: {
        widget: {
            type: Object,
            default: () => ({})
        }
    },
    setup(props) {
        const { widget } = toRefs(props)

        const classifyType = computed({
            get: () => widget.value.widgetData.eles.customFeature.classifyType,
            set: val => {
                widget.value.widgetData.eles.customFeature.classifyType = val
                if (val === 2) mode.value = 0
            }
        })

        const mode = computed({
            get: () => widget.value.widgetData.eles.customFeature.mode,
            set: val => widget.value.widgetData.eles.customFeature.mode = val
        })

        const horizontalImageSrc = computed({
            get: () => widget.value.widgetData.eles.customFeature.horizontalImageSrc,
            set: val => widget.value.widgetData.eles.customFeature.horizontalImageSrc = val
        })

        const level2ClassifyStyle = computed({
            get: () => widget.value.widgetData.eles.customFeature.level2ClassifyStyle,
            set: val => widget.value.widgetData.eles.customFeature.level2ClassifyStyle = val
        })

        return {
            widget,
            classifyType,
            mode,
            horizontalImageSrc,
            level2ClassifyStyle
        }
    }
})
</script>

<style lang="less" scoped>
.type-wrap {
    font-size: 14px;
    height: auto;
    line-height: initial;
    background: var(--edit-custome-background-color-2);
    display: flex;
    .item {
        width: 108px;
        vertical-align: middle;
        font-size: 14px;
        text-align: center;
        color: var(--edit-color-primary);
        cursor: pointer;
        & + .item {
            margin-left: 10px;
        }
        .item-list {
            height: 40px;
            border: 1px solid var(--edit-border-color-darker);
            box-sizing: border-box;
            padding: 5px;
            display: flex;
            vertical-align: middle;
            align-items: center;
            &.active {
                outline: 2px solid #2d8cf0;
            }
            div {
                width: 28px;
                height: 15px;
                margin-right: 5px;
                background-color: var(--edit-text-color-disabled);
                &:last-child {
                    margin-right: 0;
                }
            }
        }
        .item-title {
            color: var(--edit-text-color-disabled);
            margin-top: 5px;
        }
        &.type-2 {
            .item-list {
                div {
                    width: 21px;
                    height: 15px;
                    margin-right: 12px;
                    background-color: var(--edit-text-color-disabled);
                    position: relative;
                    &:after {
                        content: "";
                        position: absolute;
                        left: 15px;
                        top: 5px;
                        border-top: 5px solid var(--edit-text-color-disabled);
                        border-right: 3px solid transparent;
                        border-left: 3px solid transparent;
                        transition: all linear 0.3s;
                    }
                }
            }
        }
    }
}

.mode-wrap {
    .classify-type-1 {
        & > ul {
            line-height: 35px;
            height: 35px;
            padding: 0;
            color: var(--edit-text-color-secondary);
            text-align: center;
            font-size: 14px;
            margin-bottom: 15px;
            overflow: hidden;
            background-color: var(--edit-bg-color);
            outline: 1px solid var(--edit-border-color-darker);
            cursor: pointer;
            &.active {
                outline: 2px solid #2d8cf0;
            }
            .item {
                span {
                    padding-left: 4px;
                    padding-right: 4px;
                }
            }
        }
        .mode-0 {
            .item {
                float: left;
                width: 25%;
                &.selected {
                    span {
                        padding-top: 6px;
                        padding-bottom: 6px;
                        border-radius: 5px;
                        background-color: var(--edit-color-primary);
                        color: var(--edit-color-white);
                    }
                }
            }
        }
        .mode-1 {
            .item {
                float: left;
                width: 25%;
                &.selected {
                    color: var(--edit-color-primary);
                    border-bottom: 2px solid var(--edit-color-primary);
                }
            }
        }
        .mode-2 {
            .item {
                float: left;
                width: 25%;
                &.selected {
                    color: var(--edit-color-primary);
                }
            }
        }
        .classify-icon-wrap {
            .title-ele {
                font-size: 13px;
                margin-bottom: 15px;
            }
            .classify-icon-list-box {
                //
            }
        }
    }

    .classify-type-2 {
        & > ul {
            line-height: 35px;
            height: 35px;
            padding: 0;
            color: var(--edit-text-color-secondary);
            text-align: center;
            font-size: 14px;
            margin-bottom: 15px;
            overflow: hidden;
            background-color: var(--edit-bg-color);
            outline: 1px solid var(--edit-border-color-darker);
            cursor: pointer;
            &.active {
                outline: 2px solid #2d8cf0;
            }
            .item {
                position: relative;
                span {
                    padding-left: 4px;
                    padding-right: 4px;
                }
                .triangle {
                    position: absolute;
                    right: 7px;
                    top: 50%;
                    padding: 0;
                    border-left: 3px solid transparent;
                    border-top: 5px solid var(--edit-text-color-regular);
                    border-right: 3px solid transparent;
                    -webkit-transform: translateY(-50%);
                    transform: translateY(-50%);
                }
                .triangle2 {
                    position: absolute;
                    top: 46%;
                    right: 7px;
                    width: 5px;
                    height: 5px;
                    padding: 0;
                    border-right: 1px solid var(--edit-text-color-regular);
                    border-bottom: 1px solid var(--edit-text-color-regular);
                    -webkit-transform: translateY(-50%) rotate(45deg);
                    transform: translateY(-50%) rotate(45deg);
                }
            }
        }
        .mode-0 {
            .item {
                float: left;
                width: 25%;
                &.selected {
                    span {
                        color: var(--edit-color-primary);
                    }
                }
            }
        }
        .mode-1 {
            .item {
                float: left;
                width: 25%;
                &.selected {
                    color: var(--edit-color-primary);
                }
            }
        }
    }
}

.level2-classify-style {
    .item-wrap {
        padding: 0;
        color: var(--edit-text-color-secondary);
        font-size: 14px;
        margin-bottom: 15px;
        background-color: var(--edit-bg-color);
        outline: 1px solid var(--edit-border-color-darker);
        cursor: pointer;
        &.active {
            outline: 2px solid #2d8cf0;
        }
        & > ul {
            line-height: 35px;
            height: 35px;
            text-align: center;
            overflow: hidden;
            .item {
                position: relative;
                span {
                    padding-left: 4px;
                    padding-right: 4px;
                }
                .triangle {
                    position: absolute;
                    right: 7px;
                    top: 50%;
                    padding: 0;
                    border-left: 3px solid transparent;
                    border-top: 5px solid var(--edit-text-color-regular);
                    border-right: 3px solid transparent;
                    -webkit-transform: translateY(-50%);
                    transform: translateY(-50%);
                }
            }
        }
    }
    .mode-0 {
        .item {
            float: left;
            width: 25%;
            &.selected {
                span {
                    color: var(--edit-color-primary);
                }
                .triangle {
                    border-top: 5px solid var(--edit-color-primary);
                }
            }
        }
        .open-warp {
            font-size: 13px;
            line-height: 30px;
            padding: 0px 20px 5px 20px;
            & > div:first-child {
                color: var(--edit-color-primary);
            }
        }
    }
    .mode-1 {
        .item {
            float: left;
            width: 25%;
            &.selected {
                span {
                    color: var(--edit-color-primary);
                }
                .triangle {
                    border-top: 5px solid var(--edit-color-primary);
                }
            }
        }
        .open-warp {
            padding: 0px 15px 5px 15px;
            overflow: hidden;
            & > div {
                float: left;
                font-size: 13px;
                background-color: var(--edit-fill-color-dark);
                padding: 4px;
                border-radius: 4px;
                margin: 0px 4px 5px 4px;
                &:first-child {
                    color: var(--edit-color-primary);
                }
            }
        }
    }
}
</style>